﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.BL;
using SES.CMS.DO;

namespace SES.CMS.AdminCP.PageUC
{
    public partial class ucFAQ : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                gvHoiDapDataSource();
            }

        }

        protected void gvHoiDapDataSource()
        {
            gvHoiDap.DataSource = new cmsHoiDapBL().SelectAll();
            gvHoiDap.DataBind();
        }
        protected void gvHoiDap_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvHoiDap.PageIndex = e.NewPageIndex;
            gvHoiDapDataSource();
        }
        protected void gvHoiDap_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            new cmsHoiDapBL().Delete(new cmsHoiDapDO { HoiDapID = Convert.ToInt32(gvHoiDap.DataKeys[e.RowIndex].Value) });
            Functions.Alert("Xóa bản ghi thành công", Request.Url.ToString());
        }

        protected void gvHoiDap_SelectedIndexChanged(object sender, EventArgs e)
        {
            int HoiDapID = int.Parse(gvHoiDap.DataKeys[gvHoiDap.SelectedIndex].Value.ToString());
            Response.Redirect("Default.aspx?Page=FaqAnswer&FaqID=" + HoiDapID.ToString());
        }

        protected void gvHoiDap_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gvHoiDap.EditIndex = e.NewEditIndex;
            gvHoiDapDataSource();
        }

    }
}